
#include "rviz_custom_plugins/tools/interactive_marker_tool.h"
#include "rviz_custom_plugins/utils/interactive_marker_manager.h"
#include <rviz_common/display_context.hpp>
#include <rviz_common/tool_manager.hpp>


using rviz_custom_plugins::utils::InteractiveMarkerManager;



namespace rviz_custom_plugins
{

namespace tools {


InteractiveMarkerTool::InteractiveMarkerTool()
{

}


void InteractiveMarkerTool::load( const rviz_common::Config& config )
{
    // set marker server namespace
    QString name;
    config.mapGetString("Name", &name);
    setName(name);
    context_->getToolManager()->refreshTool(this);
    // set marker server namespace
    QString nameSpace;
    config.mapGetString("NameSpace", &nameSpace);
    markerThread = InteractiveMarkerManager::getInstance()->addThread(nameSpace);
}

void InteractiveMarkerTool::save( rviz_common::Config config ) const
{

}

void InteractiveMarkerTool::activate()
{
    if ( markerThread ) {
        markerThread->setActive(true);
    }
}

void InteractiveMarkerTool::deactivate()
{
    if(markerThread) {
        markerThread->setActive(false);
    }
}



}


}


#include <pluginlib/class_list_macros.hpp>
PLUGINLIB_EXPORT_CLASS(rviz_custom_plugins::tools::InteractiveMarkerTool, rviz_common::Tool )
